import React from 'react'
//导入 useSelector hook 函数
import {useSelector, useDispatch} from 'react-redux';
import { incre } from '../../app/slices/countSlice';
export default function ReactReduxCom() {
  //获取要使用的状态
  let count = useSelector(state => state.count);
  //获取 dispatch 函数
  let dispatch = useDispatch();
  return (
    <div>
      <h2>统计: {count}</h2>
      <button onClick={() => {
        dispatch(incre(1));
      }}>新增</button>
    </div>
  )
}
